package com.example.module_visitor.adapter

import android.graphics.Color
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.module_visitor.R
import com.yuwei.http.entity.VisitorEntityItem

class VisitorAdapter:BaseQuickAdapter<VisitorEntityItem,BaseViewHolder>(R.layout.visitor_item) {
    override fun convert(holder: BaseViewHolder, item: VisitorEntityItem) {
        if (item.visitStatus == "已通过"){
           holder.setText(R.id.visitor_item_time,item.appointmentTime)
           holder.setText(R.id.visitor_item_type,item.visitStatus)
               .setTextColor(R.id.visitor_item_type,Color.parseColor("#76B49D"))
               .setBackgroundResource(R.id.visitor_item_type, R.drawable.visitor_type_bg1)
           holder.setText(R.id.visitor_item_name,item.visitorName)
           holder.setText(R.id.visitor_item_num,item.phoneNumber)
           holder.setText(R.id.visitor_item_lfsy,"来访事由: "+item.purpose)
           holder.setText(R.id.visitor_item_lfdx,"访问对象: "+"张经理（技术部）")
            val image = holder.getView<ImageView>(R.id.visitor_item_image)
            Glide.with(context).load(R.drawable.visitor_car).into(image)
            holder.setText(R.id.visitor_item_cw,"已申请访客车牌号: "+item.plateNumber)
                .setTextColor(R.id.visitor_item_cw,Color.parseColor("#1296db"))
        }
        if (item.visitStatus == "待审核"){
            holder.setText(R.id.visitor_item_time,item.appointmentTime)
            holder.setText(R.id.visitor_item_type,item.visitStatus)
                .setTextColor(R.id.visitor_item_type,Color.parseColor("#FFAE7040"))
                .setBackgroundResource(R.id.visitor_item_type, R.drawable.visitor_type_bg2)
            holder.setText(R.id.visitor_item_name,item.visitorName)
            holder.setText(R.id.visitor_item_num,item.phoneNumber)
            holder.setText(R.id.visitor_item_lfsy,"来访事由: "+item.purpose)
            holder.setText(R.id.visitor_item_lfdx,"访问对象: "+"张经理（技术部）")
            val image = holder.getView<ImageView>(R.id.visitor_item_image)
            Glide.with(context).load(R.drawable.visitor_normal_car).into(image)
            holder.setText(R.id.visitor_item_cw,"未申请访客车位 ")
                .setTextColor(R.id.visitor_item_cw,Color.parseColor("#999999"))
        }
        if (item.visitStatus == "驳回"){
            holder.setText(R.id.visitor_item_time,item.appointmentTime)
            holder.setText(R.id.visitor_item_type,item.visitStatus)
                .setTextColor(R.id.visitor_item_type,Color.parseColor("#999999"))
                .setBackgroundResource(R.id.visitor_item_type, R.drawable.visitor_type_bg3)
            holder.setText(R.id.visitor_item_name,item.visitorName)
            holder.setText(R.id.visitor_item_num,item.phoneNumber)
            holder.setText(R.id.visitor_item_lfsy,"来访事由: "+item.purpose)
            holder.setText(R.id.visitor_item_lfdx,"访问对象: "+"张经理（技术部）")
            val image = holder.getView<ImageView>(R.id.visitor_item_image)
            Glide.with(context).load(R.drawable.visitor_normal_car).into(image)
            holder.setText(R.id.visitor_item_cw,"未申请访客车位 ")
                .setTextColor(R.id.visitor_item_cw,Color.parseColor("#999999"))
        }
    }
}